package com.material.web.controller.factory;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.material.common.annotation.Log;
import com.material.common.core.controller.BaseController;
import com.material.common.core.domain.AjaxResult;
import com.material.common.enums.BusinessType;
import com.material.factory.domain.FactorySupplierConfig;
import com.material.factory.service.IFactorySupplierConfigService;
import com.material.common.utils.poi.ExcelUtil;
import com.material.common.core.page.TableDataInfo;

/**
 * 工厂供应商预约燃料比例分配Controller
 * 
 * @author ruoyi
 * @date 2025-05-07
 */
@RestController
@RequestMapping("/factory/config")
public class FactorySupplierConfigController extends BaseController
{
    @Autowired
    private IFactorySupplierConfigService factorySupplierConfigService;

    /**
     * 查询工厂供应商预约燃料比例分配列表
     */
    @PreAuthorize("@ss.hasPermi('factory:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(FactorySupplierConfig factorySupplierConfig)
    {
        startPage();
        List<FactorySupplierConfig> list = factorySupplierConfigService.selectFactorySupplierConfigList(factorySupplierConfig);
        return getDataTable(list);
    }

    /**
     * 导出工厂供应商预约燃料比例分配列表
     */
    @PreAuthorize("@ss.hasPermi('factory:config:export')")
    @Log(title = "工厂供应商预约燃料比例分配", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FactorySupplierConfig factorySupplierConfig)
    {
        List<FactorySupplierConfig> list = factorySupplierConfigService.selectFactorySupplierConfigList(factorySupplierConfig);
        ExcelUtil<FactorySupplierConfig> util = new ExcelUtil<FactorySupplierConfig>(FactorySupplierConfig.class);
        util.exportExcel(response, list, "工厂供应商预约燃料比例分配数据");
    }

    /**
     * 获取工厂供应商预约燃料比例分配详细信息
     */
    @PreAuthorize("@ss.hasPermi('factory:config:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(factorySupplierConfigService.selectFactorySupplierConfigById(id));
    }

    /**
     * 新增工厂供应商预约燃料比例分配
     */
    @PreAuthorize("@ss.hasPermi('factory:config:add')")
    @Log(title = "工厂供应商预约燃料比例分配", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FactorySupplierConfig factorySupplierConfig)
    {
        return toAjax(factorySupplierConfigService.insertFactorySupplierConfig(factorySupplierConfig));
    }

    /**
     * 修改工厂供应商预约燃料比例分配
     */
    @PreAuthorize("@ss.hasPermi('factory:config:edit')")
    @Log(title = "工厂供应商预约燃料比例分配", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FactorySupplierConfig factorySupplierConfig)
    {
        return toAjax(factorySupplierConfigService.updateFactorySupplierConfig(factorySupplierConfig));
    }

    /**
     * 删除工厂供应商预约燃料比例分配
     */
    @PreAuthorize("@ss.hasPermi('factory:config:remove')")
    @Log(title = "工厂供应商预约燃料比例分配", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(factorySupplierConfigService.deleteFactorySupplierConfigByIds(ids));
    }
}
